All Packages Class Hierarchy This Package Previous Next Index
Class sunw.demo.buttons.OurButton
java.lang.Object
|
+----java.awt.Component
|
+----sunw.demo.buttons.OurButton
- public class OurButton
- extends Component
- implements Serializable, MouseListener, MouseMotionListener
A simple Java Beans button. OurButton is a "from-scratch"
lightweight AWT component. It's a good example of how to
implement bound properties and support for event listeners.
Parts of the source are derived from sun.awt.tiny.TinyButtonPeer.
-
OurButton()
- Constructs a Button with the a default label.
-
OurButton(String)
- Constructs a Button with the specified label.
-
addActionListener(ActionListener)
- The specified ActionListeners actionPerformed method will
be called each time the button is clicked.
-
addPropertyChangeListener(PropertyChangeListener)
- The specified PropertyChangeListeners propertyChange method will
be called each time the value of any bound property is changed.
-
fireAction()
-
This method has the same effect as pressing the button.
-
getDebug()
-
Returns true if debugging output is enabled.
-
getFontSize()
-
Return the current font point size.
-
getLabel()
- Returns the buttons label.
-
getMinimumSize()
-
-
getPreferredSize()
-
-
isLargeFont()
-
Returns true if the font is "large" in the sense defined by setLargeFont.
-
minimumSize()
-
Deprecated.
-
mouseClicked(MouseEvent)
-
-
mouseDragged(MouseEvent)
-
-
mouseEntered(MouseEvent)
-
-
mouseExited(MouseEvent)
-
-
mouseMoved(MouseEvent)
-
-
mousePressed(MouseEvent)
-
-
mouseReleased(MouseEvent)
-
-
paint(Graphics)
- Paint the button: the label is centered in both dimensions.
-
preferredSize()
-
Deprecated.
-
removeActionListener(ActionListener)
-
Remove this ActionListener from the buttons internal list.
-
removePropertyChangeListener(PropertyChangeListener)
-
Remove this PropertyChangeListener from the buttons internal list.
-
setBackground(Color)
- Set the color the buttons background is drawn with.
-
setDebug(boolean)
-
Enable debugging output.
-
setFont(Font)
- Set the current font and change its size to fit.
-
setFontSize(int)
-
Set the point size of the current font.
-
setForeground(Color)
- Set the color the buttons label is drawn with.
-
setLabel(String)
-
Set the buttons label and change it's size to fit.
-
setLargeFont(boolean)
-
Set the font size to 18 if true, 12 otherwise.
OurButton
public OurButton()
- Constructs a Button with the a default label.
OurButton
public OurButton(String label)
- Constructs a Button with the specified label.
- Parameters:
- label - the label of the button
paint
public synchronized void paint(Graphics g)
- Paint the button: the label is centered in both dimensions.
- Overrides:
- paint in class Component
mouseClicked
public void mouseClicked(MouseEvent evt)
mousePressed
public void mousePressed(MouseEvent evt)
mouseReleased
public void mouseReleased(MouseEvent evt)
mouseEntered
public void mouseEntered(MouseEvent evt)
mouseExited
public void mouseExited(MouseEvent evt)
mouseDragged
public void mouseDragged(MouseEvent evt)
mouseMoved
public void mouseMoved(MouseEvent evt)
addActionListener
public synchronized void addActionListener(ActionListener l)
- The specified ActionListeners actionPerformed method will
be called each time the button is clicked. The ActionListener
object is added to a list of ActionListeners managed by
this button, it can be removed with removeActionListener.
Note: the JavaBeans specification does not require ActionListeners
to run in any particular order.
- Parameters:
- l - the ActionListener
- See Also:
- removeActionListener
removeActionListener
public synchronized void removeActionListener(ActionListener l)
- Remove this ActionListener from the buttons internal list. If the
ActionListener isn't on the list, silently do nothing.
- Parameters:
- l - the ActionListener
- See Also:
- addActionListener
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener l)
- The specified PropertyChangeListeners propertyChange method will
be called each time the value of any bound property is changed.
The PropertyListener object is addded to a list of PropertyChangeListeners
managed by this button, it can be removed with removePropertyChangeListener.
Note: the JavaBeans specification does not require PropertyChangeListeners
to run in any particular order.
- Parameters:
- l - the PropertyChangeListener
- See Also:
- removePropertyChangeListener
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener l)
- Remove this PropertyChangeListener from the buttons internal list.
If the PropertyChangeListener isn't on the list, silently do nothing.
- Parameters:
- l - the PropertyChangeListener
- See Also:
- addPropertyChangeListener
fireAction
public void fireAction()
- This method has the same effect as pressing the button.
- See Also:
- addActionListener
setDebug
public void setDebug(boolean x)
- Enable debugging output. Currently a message is printed each time
the button is clicked. This is a bound property.
- See Also:
- getDebug, addPropertyChangeListener
getDebug
public boolean getDebug()
- Returns true if debugging output is enabled.
- See Also:
- setDebug
setLargeFont
public void setLargeFont(boolean b)
- Set the font size to 18 if true, 12 otherwise. This property overrides
the value specified with setFontSize. This is a bound property.
- See Also:
- isLargeFont, addPropertyChangeListener
isLargeFont
public boolean isLargeFont()
- Returns true if the font is "large" in the sense defined by setLargeFont.
- See Also:
- setLargeFont, setFont
setFontSize
public void setFontSize(int x)
- Set the point size of the current font. This is a bound property.
- See Also:
- getFontSize, setFont, setLargeFont, addPropertyChangeListener
getFontSize
public int getFontSize()
- Return the current font point size.
- See Also:
- setFontSize
setFont
public void setFont(Font f)
- Set the current font and change its size to fit. This is a
bound property.
- Overrides:
- setFont in class Component
- See Also:
- setFontSize, setLargeFont
setLabel
public void setLabel(String newLabel)
- Set the buttons label and change it's size to fit. This is a
bound property.
- See Also:
- getLabel
getLabel
public String getLabel()
- Returns the buttons label.
- See Also:
- setLabel
getPreferredSize
public Dimension getPreferredSize()
- Overrides:
- getPreferredSize in class Component
preferredSize
public Dimension preferredSize()
- Note: preferredSize() is deprecated.
provided for backward compatibility with old layout managers.
- Overrides:
- preferredSize in class Component
getMinimumSize
public Dimension getMinimumSize()
- Overrides:
- getMinimumSize in class Component
minimumSize
public Dimension minimumSize()
- Note: minimumSize() is deprecated.
provided for backward compatibility with old layout managers.
- Overrides:
- minimumSize in class Component
setForeground
public void setForeground(Color c)
- Set the color the buttons label is drawn with. This is a bound property.
- Overrides:
- setForeground in class Component
setBackground
public void setBackground(Color c)
- Set the color the buttons background is drawn with. This is a bound property.
- Overrides:
- setBackground in class Component
All Packages Class Hierarchy This Package Previous Next Index